
function Loaded() 
{						
	var l = document.getElementById("LoadingDiv");						
	l.style.visibility = "hidden";			
}	
/*Gallery*/
function hideLoading()
{
	var imagePreview = document.getElementById("<%= imagePreview.ClientID %>");
	if (imagePreview) imagePreview.style.display = "block";
	var panelImagePreviewLoading = document.getElementById("<%= panelImagePreviewLoading.ClientID %>");
	if (panelImagePreviewLoading) panelImagePreviewLoading.style.display = "none";
	var panelLoadingImage = document.getElementById("<%= panelLoadingImage.ClientID %>");
	if (panelLoadingImage) panelLoadingImage.style.display = "none";
}

function showLoading()
{
	var imagePreview = document.getElementById("<%= imagePreview.ClientID %>");
	if (imagePreview) imagePreview.style.display = "none";
	var panelImagePreviewLoading = document.getElementById("<%= panelImagePreviewLoading.ClientID %>");
	if (panelImagePreviewLoading) panelImagePreviewLoading.style.display = "block";
	var panelLoadingImage = document.getElementById("<%= panelLoadingImage.ClientID %>");
	if (panelLoadingImage) panelLoadingImage.style.display = "block";
}
function showCallbackImage(srcElement)
	{
		callbackImageGallery.MakeCallback("ShowImage", srcElement.src);
		//objImage = document.getElementById("imageShow");
		//if(objImage != null) objImage.src = srcElement.src;
	}
	function buttonEditClicked()
	{
		var panelViewImage = document.getElementById("<%= viewPanel.ClientID %>");
		panelViewImage.style.display = "none";
		var panelEditImage = document.getElementById("<%= editPanel.ClientID %>");
		panelEditImage.style.display = "block";
	}
	function buttonUpdateClicked()
	{
		var panelViewImage = document.getElementById("<%= viewPanel.ClientID %>");
		panelViewImage.style.display = "block";
		var panelEditImage = document.getElementById("<%= editPanel.ClientID %>");
		panelEditImage.style.display = "none";
		callbackImageGallery.MakeCallback("UpdateImageSettings",null);
	}
	function buttonCancelClicked()
	{
		var panelViewImage = document.getElementById("<%= viewPanel.ClientID %>");
		panelViewImage.style.display = "block";
		var panelEditImage = document.getElementById("<%= editPanel.ClientID %>");
		panelEditImage.style.display = "none";
	}
/*End Gallery*/
/*Music*/
function Play(mediaId){
	window.open('/PlayMedia.aspx?mediaid=' + mediaId, 400, 300);
}
/*End Music*/
function Colapse(id){
		obj = document.getElementById(id);
		img = document.getElementById(obj.id + "arrow");
		if(obj != null){
			if(obj.style.display == "block"){
				obj.style.display = "none";
				img = document.getElementById(obj.id + "arrow");
				if(img != null) img.src = "/Images/arrowdown.bmp";
			}else{
				obj.style.display = "block";
				if(img != null) img.src = "/Images/arrowup.bmp";
			}
		}
	}
	function Show(id){
		obj = document.getElementById(id);
		if(obj != null){
			obj.style.display = "block";
		}
	}
	
//------------------------------------------------------------

//su dung cho ham check all
function IsMatch(id,pattern) 
{  
    var regularExpresssion = new RegExp(pattern); 
    
    if(id.match(regularExpresssion)) return true; 
    else return false; 
}
//su dung cho ham check all
function IsCheckBox(chk) 
{
    if(chk.type == 'checkbox') return true; 
    else return false;
}

//ham check all
function Check(parentChk,gridName) 
{
    var elements =  document.getElementsByTagName("INPUT"); 

    
    
    for(i=0; i<elements.length;i++) 
    {
        if(parentChk.checked == true) 
        {  
            if( IsCheckBox(elements[i]) &&  IsMatch(elements[i].id,gridName)) 
            {
            elements[i].checked = true; 
            }         
        }
        else 
        {
            elements[i].checked = false; 
         
            counter = 0; 
        }       
    }
    
}

//ham doi mau
function highlightChkBxRow(chkbx) 
		{
        if (chkbx.id.indexOf ('DeleteThis') != -1)
		{
			if (chkbx.checked)
				{
				chkbx.parentElement.parentElement.style.backgroundColor='#F5EDED';
				chkbx.parentElement.parentElement.style.color='#000FFF'; 
				chkbx.parentElement.parentElement.setAttribute("class", "postheader");
				//alert(chkbx.parentElement.parentElement.style.backgroundColor);
				}
				else
				{
				chkbx.parentElement.parentElement.setAttribute("class", "post");
				//chkbx.parentElement.parentElement.style.backgroundColor='#FFFFFF';
				//chkbx.parentElement.parentElement.style.color='#000000'; 
				}
			}
		else
			{
			var frm = document.forms[0];
			for (h = 0; h < frm.length; h++)
				{
				if (frm.elements[h].id.indexOf ('DeleteThis') != -1)
					{
					if (chkbx.id.indexOf ('chkAll') != -1 && chkbx.checked) 
						{
						frm.elements[h].parentElement.parentElement.style.backgroundColor='#F5EDED';
						frm.elements[h].parentElement.parentElement.style.color='#000000';
					
						}
					else
						{
						frm.elements[h].parentElement.parentElement.style.backgroundColor='#FFFFFF';
						frm.elements[h].parentElement.parentElement.style.color='#000000';
						
						}
					}
				} 
            }
        }
  //ham confirm      
 function confirmMsg(frm)
    {
    for (i = 0; i < frm.length; i++)
        {
        if (frm.elements[i].name.indexOf("DeleteThis") !=  - 1)
            {
            if (frm.elements[i].checked)
            return confirm('Are you sure you want to delete your selection(s)?')
            }
        }
    }
